def decodeString(s):
    def decode(i):
        res = ""
        num = 0
        while (i<len(s)):
            if"0"<=s[i]<="9":
                num = num * 10 + int(s[i])
            elif s[i]=='[':
                i,temp = decode(i+1)
                res = res + num * temp
                num = 0
            elif s[i] == ']':
                return i,res
            else:
                res = res +s[i]
            i = i + 1
        return res
    return decode(0)
print(decodeString('3[a]2[c]'))